package model;

import command.CommandMarquerTemps;
import command.CommandStart;

import observer.Observer;
import observer.Subject;

import controller.ControllerImpl;

public class MoteurMetronomeImpl implements MoteurMetronome, Subject{

	private Observer observer;
	private double tempo;
	private int tempsParMesure;
	private boolean etatMarche;
	private HorlogeImpl horloge;

	private CommandMarquerTemps cmdMarquerTemps;

	public MoteurMetronomeImpl(){
		observer = null;
		//cmdMarquerTemps = new CommandMarquerTemps(controller,this);
		horloge = new HorlogeImpl();
	}


	public boolean getEtatMarche() {
		return etatMarche;
	}

	public double getTempo() {
		return tempo;
	}


	public int getTempsParMesure() {
		return tempsParMesure;
	}


	public void setEtatMarche(boolean em) {
		this.etatMarche = em;
		notifyObserver(this);
	}


	public void setTempo(double t) {
		this.tempo = t;
		notifyObserver(this);
	}


	public void setTempsParMesure(int tpm) {
		this.tempsParMesure = tpm;
		notifyObserver(this);
	}

	public void traiterTic() {

	}

	public Observer getObserver(){
		return observer;
	}

	public void attach(Observer o) {
		this.observer = (Observer) o;
	}

	public void detach(Observer o) {
		if(observer==o){
			observer=null;
		}

	}

	public void notifyObserver(Subject s){
		observer.updateByMoteurMetronome(this);
	}

}
